﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Resources;
using System.Text;
using System.Windows.Forms;
using PBO.Data;
using PBO.Util;
using PBO.Game.Img;

namespace PBO.Forms
{
    [ToolboxItem(true)]
    public partial class MoveGridView : UserControl
    {
        public MoveGridView()
        {
            InitializeComponent();
        }

        public void BindDataTable(DataTable table)
        {
            this.dgvMove.DataSource = table;
        }


        public void FindName()
        {




        }

        public DataGridView MoveGrid
        {
            get { return this.dgvMove; }
        }

        #region event

        private void dgvMove_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (dgvMove.Columns[e.ColumnIndex] == MvColTypeImg)
            {
                e.Value = ImageHelper.GetTypeImage(Convert.ToInt32(dgvMove[MvColType.Name, e.RowIndex].Value));
            }
            else if (dgvMove.Columns[e.ColumnIndex] == MvColCategoryImg)
            {
                e.Value = ImageHelper.GetCategoryImage(Convert.ToInt32(dgvMove[MvColCategory.Name, e.RowIndex].Value));
            }
        }

        private void dgvMove_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (dgvMove.Columns[e.ColumnIndex] == MvColTypeImg)
            {
                dgvMove.Sort(dgvMove.Columns[MvColType.Name], ListSortDirection.Ascending);
            }
            else if (dgvMove.Columns[e.ColumnIndex] == MvColCategoryImg)
            {
                dgvMove.Sort(dgvMove.Columns[MvColCategory.Name], ListSortDirection.Ascending);
            }
        }

        #endregion

    }
}
